﻿<div style="margin-bottom: 20px; margin-left: 10px;" class="pagination">
    Found Orders: 
        <span style="color: blue">@ViewBag.OrdersCount</span>
    <span style="margin-left: 440px;" class="pagination">
        @if (ViewBag.itemOnPage == 10)
        {
            @Ajax.ActionLink("25 item on page", "OrderTable", new { itemOnPage = 25, page = ViewBag.currentPage}, new AjaxOptions { UpdateTargetId = "table", LoadingElementId = "loading", LoadingElementDuration = 1000 })
            }
        else
        {
            @Ajax.ActionLink("10 item on page", "OrderTable", new { itemOnPage = 10, page = ViewBag.currentPage}, new AjaxOptions { UpdateTargetId = "table", LoadingElementId = "loading", LoadingElementDuration = 1000 })
    
            }
    </span>
</div>
<br />
<table class="rounded-corner">
    <thead>
        <tr>
            <th class="rounded-company">@Html.ActionLink("Order Id", "Index")</th>
            <th>@Html.ActionLink("Total Price", "Index")</th>
            <th>@Html.ActionLink("Discount", "Index")</th>
            <th>@Html.ActionLink("Delivery Date", "Index")</th>
            <th>@Html.ActionLink("Status", "Index")</th>
            <th>@Html.ActionLink("Assignee", "Index")</th>
            <th class="rounded-q4">Operate</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var c in ViewBag.Orders)
        {
            <tr>
                <td>@Html.ActionLink("View", "OrderDetails", new { orderId = c.OrderId })</td>
                <td>@c.TotalPrice</td>
                <td>0%</td>
                <td>@c.DeliveryDate.ToString("dd:MM:yyyy")</td>
                <td>Ordered</td>
                <td>@c.Assigned</td>

                <td><a href="#">
                    <img src="../../Content/images/user_edit.png" alt="" title="" border="0" /></a>
                    <a href="#" class="ask">
                        <img src="../../Content/images/trash.png" alt="" title="" border="0" /></a></td>

            </tr>
            }
        @if (ViewBag.Orders.Count != ViewBag.itemOnPage)
        {
            for (int i = 0; i < ViewBag.itemOnPage - ViewBag.Orders.Count; i++)
            {
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        }
    }

    </tbody>
</table>
<div class="pagination">


    @if (ViewBag.currentPage == 1)
    {
        <span class="disabled">first</span>
        <span class="disabled">< prev</span>
         }
    else
    {
        <span>

            @Ajax.ActionLink("first", "OrderTable", new
       {

           itemOnPage = ViewBag.itemOnPage,
           page = 1

       }, new AjaxOptions
       {
           UpdateTargetId = "table",
           LoadingElementId = "loading",
           LoadingElementDuration = 1000
       })

        </span>
             
        <span>
            @Ajax.ActionLink("< prev", "OrderTable", new
       {
           itemOnPage = ViewBag.itemOnPage,
           page = ViewBag.currentPage - 1

       }, new AjaxOptions
       {
           UpdateTargetId = "table",
           LoadingElementId = "loading",
           LoadingElementDuration = 1000
       })

        </span>
             
             
         }
    @if (ViewBag.OrdersCount <= ViewBag.currentPage * ViewBag.itemOnPage)
    {
        <span class="disabled">next ></span>
        <span class="disabled">last</span>
         }
    else
    {
        <span>

            @Ajax.ActionLink("next >", "OrderTable", new
       {
           itemOnPage = ViewBag.itemOnPage,
           page = ViewBag.currentPage + 1

       }, new AjaxOptions
       {
           UpdateTargetId = "table",
           LoadingElementId = "loading",
           LoadingElementDuration = 1000
       })

        </span>
        <span>
            @Ajax.ActionLink("last", "OrderTable", new
       {
           itemOnPage = ViewBag.itemOnPage,
           page = ViewBag.lastPage

       }, new AjaxOptions
       {
           UpdateTargetId = "table",
           LoadingElementId = "loading",
           LoadingElementDuration = 1000
       })

        </span>
            }
</div>
